package top.krwlc.server.pojo;

import top.krwlc.server.util.DateUtil;

import java.text.ParseException;
import java.util.Date;

/**
 * krwlc
 * top.krwlc.server.pojo
 *
 * @author Lanscarlos
 * @since 2022-04-05 11:44
 */
public class User {

    /* 用户 id */
    private String uid;

    /* 昵称 */
    private String display;

    /* 密码（加密后） */
    private String password;

    /* 姓名 */
    private String name;

    /* 身份证号 */
    private String identityCode;

    /* 手机号 */
    private String phone;

    /* 注册日期 */
    private Date regTime;

    /* 出生日期 */
    private Date birth;

    /* 年龄 */
    private int arg;

    /**
     * 注册用户时调用
     * */
    public User(String uid, String display, String password, String name, String identityCode, String phone) throws ParseException {
        this.uid = uid;
        this.display = display;
        this.password = password;
        this.name = name;
        this.identityCode = identityCode;
        this.phone = phone;

        this.regTime = new Date();
        this.birth = DateUtil.extractBirth(identityCode);
        this.arg = DateUtil.calcAge(this.birth);
    }

    /**
     * 从数据库获取用户时调用
     * */
    public User(String uid, String display, String password, String name, String identityCode, String phone, Date regTime, Date birth) {
        this.uid = uid;
        this.display = display;
        this.password = password;
        this.name = name;
        this.identityCode = identityCode;
        this.phone = phone;
        this.regTime = regTime;
        this.birth = birth;

        this.arg = DateUtil.calcAge(birth);
    }

    public String getUid() {
        return uid;
    }

    public void setUid(String uid) {
        this.uid = uid;
    }

    public String getDisplay() {
        return display;
    }

    public void setDisplay(String display) {
        this.display = display;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getIdentityCode() {
        return identityCode;
    }

    public void setIdentityCode(String identityCode) {
        this.identityCode = identityCode;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public Date getRegTime() {
        return regTime;
    }

    public void setRegTime(Date regTime) {
        this.regTime = regTime;
    }

    public int getArg() {
        return arg;
    }

    public void setArg(int arg) {
        this.arg = arg;
    }

    public Date getBirth() {
        return birth;
    }

    public void setBirth(Date birth) {
        this.birth = birth;
    }
}
